package com.wwwarehouse.usercenter.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wwwarehouse.usercenter.R;
import com.wwwarehouse.usercenter.bean.authoritydistribute.GetFailDetailResponseBean;

import java.util.List;

/**
 * @author : mundane
 * @time : 2017/9/24 13:15
 * @description :
 * @file : AuthorityDistributeFailDetailRvAdapter.java
 */
public class AuthorityDistributeFailDetailRvAdapter extends RecyclerView.Adapter<AuthorityDistributeFailDetailRvAdapter.AuthorityDistributeDetailRvAdapterHolder> {

	private List<GetFailDetailResponseBean.ListBean> mDataList;

	public AuthorityDistributeFailDetailRvAdapter(List<GetFailDetailResponseBean.ListBean> dataList) {
		this.mDataList = dataList;
	}

	@Override
	public AuthorityDistributeDetailRvAdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_detail_auth_distribute, parent, false);
		return new AuthorityDistributeDetailRvAdapterHolder(view);
	}

	@Override
	public void onBindViewHolder(AuthorityDistributeDetailRvAdapterHolder holder, int position) {
		GetFailDetailResponseBean.ListBean listBean = mDataList.get(position);

		holder.mTvAuthName.setText(listBean.authName);
		holder.mTvReason.setText(listBean.detailMsg);
		// process data
	}

	@Override
	public int getItemCount() {
		return mDataList == null ? 0 : mDataList.size();
	}

	static class AuthorityDistributeDetailRvAdapterHolder extends RecyclerView.ViewHolder {

		TextView mTvReason;
		TextView mTvAuthName;

		public AuthorityDistributeDetailRvAdapterHolder(View itemView) {
			super(itemView);
			mTvAuthName = (TextView) itemView.findViewById(R.id.tv_authName);
			mTvReason = (TextView) itemView.findViewById(R.id.tv_detail_msg);
		}
	}
}
